// pages/addComment/addComment.js
const util = require('../../utils/util.js')

const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
		history: {},
		user: {},
		commentType: 0,
		reason: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
		var trade = app.globalData.trade
		console.log(trade)
		// if(trade.information.status = '单方完成'){
		// 	trade.indent.status = '已完成'
		// 	trade.information.status = '已完成'
		// }else{
		// 	trade.indent.status = '单方完成'
		// 	trade.information.status = '单方完成'
		// }
		util.getUser(this)

		this.setData({
			history: trade
		})
  },

	radioChange: function(e) {
		this.setData({
			commentType: e.detail.value
		})
	},

	bindTextAreaBlur: function (e) {1
		this.setData({
			reason: e.detail.value
		})
	},
	
	addComment: function() {
		util.addComment(this.data.history.indent.indentId, this.data.reason, this.data.commentType, app.globalData.userId, function() {
			
		})
		wx.switchTab({
			url: '/pages/trade/trade',
		})
	}
})